﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <script src="js/0_common/jquery.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .fgsq .layui-form-select .layui-input {
        padding-right: 0 !important;
    }
</style>
<body class="fgsq">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>企业复工复产服务</legend>
</fieldset>
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
    <legend>防护物资储备</legend>
<form class="layui-form" lay-filter="form-test" action=""  id="example" method="post">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">物资报备日期</label>
                <div class="layui-input-block">
                    <input type="text" name="zd25" id="date2" lay-verify="date|required" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否有应急药品</label>
                <div class="layui-input-block">
                    <div style="width: 182px;">
                        <input type="radio" name="zd26" value="是" title="是">
                        <input type="radio" name="zd26" value="否" title="否" checked>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">口罩数量（个）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd27" name="zd27" lay-verify="required" autocomplete="off" placeholder="请输入口罩数量（个）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">口罩可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd28" name="zd28" lay-verify="numberRange" autocomplete="off" placeholder="请输入口罩可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">75%酒精数量（ml）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd29" name="zd29" lay-verify="required" autocomplete="off" placeholder="请输75%酒精量（ml）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">75%酒精可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd30" name="zd30" lay-verify="numberRange" autocomplete="off" placeholder="请输入75%酒精可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">橡胶手套（双）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd31" name="zd31" lay-verify="required" autocomplete="off" placeholder="请输入橡胶手套（双）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">橡胶手套可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd32" name="zd32" lay-verify="numberRange" autocomplete="off" placeholder="请输入橡胶手套可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">肥皂数量（块）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd33" name="zd33" lay-verify="required" autocomplete="off" placeholder="请输入肥皂数量（块）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">肥皂可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd34" name="zd34" lay-verify="numberRange" autocomplete="off" placeholder="请输入肥皂可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">测温仪器数量（个）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd35" name="zd35" lay-verify="required" autocomplete="off" placeholder="请输入测温仪器数量（个）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">测温仪器可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd36" name="zd36" lay-verify="numberRange" autocomplete="off" placeholder="请输入测温仪器可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">84消毒液量（ml）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd37" name="zd37" lay-verify="required" autocomplete="off" placeholder="请输入84消毒液量（ml）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">84消毒液可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd38" name="zd38" lay-verify="numberRange" autocomplete="off" placeholder="请输入84消毒液可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">消毒洗手液量（ml）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd39" name="zd39" lay-verify="required" autocomplete="off" placeholder="请输入消毒洗手液量（ml）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">消毒洗手液可用天数（天）</label>
                <div class="layui-input-block">
                    <input type="text" id="zd40" name="zd40" lay-verify="numberRange" autocomplete="off" placeholder="请输入消毒洗手液可用天数（天）" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">

                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1" id="save">保存</button>
                <button class="layui-btn" id="next" lay-submit="" lay-filter="next" style="display: none">下一步</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <!--            <button class="layui-btn" lay-submit="" lay-filter="demo1">下一步</button>-->
            </div>
        </div>
</form>

</fieldset>
<ul class="layui-timeline" style="display: block" id="time">

</ul>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/constants.js"></script>
<script src="js/0_common/jquery.min.js"></script>
<script src="layui/jquery.serializejson.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var ctx = Constants.path;
    var qyid = localStorage.getItem('qyid');

    layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate,
            upload = layui.upload
        $.ajax({
            type: "get",
            url: ctx + "pb/qysqbs/findall",
            data:{
                "qyid":qyid
            },
            success: function(res) {

                if (res.data.length > 0 && res.data[res.data.length - 1].zd25!=null) {
                    var lastIndex = res.data.length - 1;
                    var currentTable = res.data[lastIndex];
                    form.val('form-test', currentTable);
                }
            }});

        //日期
        // laydate.render({
        //     elem: '#date'
        // });
        // laydate.render({
        //     elem: '#date1',
        //     value: new Date()
        // });
        laydate.render({
            elem: '#date2',
            value: new Date()
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请填写内容！';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                if(value.length < 18){
                    return '信用代码填写不正确！';
                }
            },
            numberRange: function (value) {
                if (!value || value == ' ') {
                    return '请填写必填项'
                }
                if (value < 5) {
                    return '天数必须大于等于5天'
                }
            }
        });
        form.on("submit(next)", function () {
            window.location.href = "./Four_scfj.html";
            return false;
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            $('#save').attr({'disabled':'disabled'});
            var obj1 = $("#example").serializeJSON()
            var obj = {
                'zd25': obj1.zd25,

                'zd27': obj1.zd27,
                'zd28': obj1.zd28,

                'zd29': obj1.zd29,
                'zd30': obj1.zd30,

                'zd31':obj1.zd31,
                'zd32':obj1.zd32,

                'zd33':obj1.zd33,
                'zd34':obj1.zd34,

                'zd35': obj1.zd35,
                'zd36': obj1.zd36,

                'zd37': obj1.zd37,
                'zd38': obj1.zd38,

                'zd39': obj1.zd39,
                'zd40': obj1.zd40,

                'zd26': obj1.zd26,
                'qyid': qyid,
            };
            $.ajax({
                type: "post",
                url: ctx + "pv/cjqysqbs",
                data: JSON.stringify(obj),
                dataType:"json",
                contentType:"application/json",
                success: function(r) {
                    if (r.code == "200"){
                        layer.msg('提交成功！', {
                            icon: 1,
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                           $('#next').show();
                            $('#save').removeAttr('disabled');
                        });
                    }else {
                        layer.msg('提交失败');
                        $('#save').removeAttr('disabled');
                    }
                }
            });
            return false;
        });
    });
    //上报
    function sb(qyid) {
        $.ajax({
            type: "put",
            url: ctx + "pv/qyxxs/"+qyid,
            data: JSON.stringify({
                "status":"2"
            }),
            dataType:"json",
            contentType:"application/json",
            success: function(r) {
                if (r.code == "200"){
                    layer.msg('上报成功！', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        window.location.href = "test.html"
                    });
                }else {
                    layer.msg('提交失败');
                }
            }
        });
    }

    //查看详情
    function ck(id) {
        layer.open({
            type: 2,
            title:"申报详情",
            content: 'testXq.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    //修改
    function xg(id) {
        layer.open({
            type: 2,
            title:"申报-修改",
            content: 'testXg.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    checkStatus();
    function checkStatus(cb) {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200"){
                    if (r.data.status >= 2) {
                        window.location.href = 'test.html'
                    } else {
                        if (cb) {
                            cb();
                        }
                    }
                }
            }
        });
    }

</script>

</body>
</html>
